import { ApiProperty } from '@nestjs/swagger';
import { IsAlpha, IsBoolean, IsEmail, IsMobilePhone, IsNotEmpty, IsNumber, IsOptional, IsString, MaxLength, MinLength } from 'class-validator';

export class UpdateUserAdminReqDto {
  @ApiProperty({ description: '用户唯一标识：用户名/手机号/邮箱', required: false })
  @MaxLength(50, { message: '用户名不能超过50位' })
  @MinLength(2, { message: '用户名最低为2位' })
  @IsNotEmpty({ message: '用户名不能为空' })
  @IsAlpha(undefined, { message: '用户名只能包含字母(a-zA-Z)' })
  @IsOptional()
  readonly username: string;

  @ApiProperty({ description: '显示名称', required: false })
  @IsString({ message: '显示名称格式不正确' })
  @IsOptional()
  readonly display_name?: string;

  @ApiProperty({ description: '岗位编号', required: false })
  @IsNumber({}, { message: '当前岗位编号格式不正确' })
  @IsOptional()
  readonly job_id: number;

  @ApiProperty({ description: '用户组织编号列表', required: false })
  @IsNumber({}, { each: true, message: '用户组织编号列表格式不正确' })
  @IsOptional()
  readonly organization_id_list: number[];

  @ApiProperty({ description: '是否启用', required: false })
  @IsBoolean({ message: '是否启用格式不正确' })
  @IsOptional()
  readonly active: boolean;

  @ApiProperty({ description: '邮箱', required: false })
  @IsEmail({}, { message: '邮箱格式不正确' })
  @IsOptional()
  readonly email: string;

  @ApiProperty({ description: '手机号码', required: false })
  @IsMobilePhone('zh-CN', undefined, { message: '手机号码格式不正确' })
  @IsOptional()
  readonly mobile: string;
}
